package com.sitechasia.webx.components.xtable.customertag;

import org.apache.commons.lang.StringUtils;
import org.extremecomponents.table.bean.Row;
import org.extremecomponents.table.core.TableModel;
import org.extremecomponents.table.view.html.RowBuilder;
import org.extremecomponents.util.HtmlBuilder;

/**
*
* <p>版权所有：中企动力
* <p>未经本公司许可，不得以任何方式复制或使用本程序任何部分
* <p>功能描述：列表行生成类
*
* @author kuanglingxuan
* Created on 2007-8-15
*/
public class CeRowBuilder extends RowBuilder {

	protected HtmlBuilder html;
	protected TableModel model;
	protected Row row;

	public CeRowBuilder(HtmlBuilder html, TableModel model) {
		super(html, model);
		this.html = html;
        this.model = model;
        row = model.getRowHandler().getRow();

	}

	/**
	 * 功能描述：重写父类rowStart方法加入id()、ondblclick()两个方法
	 */
	public void rowStart()
    {
        html.tr(1);
        styleClass();
        style();
        onclick();
        onmouseover();
        onmouseout();
        id();
        ondblclick();
        onContextMenu();
        html.close();
    }

	/**
	 * 功能描述：生成每行tr的id
	 */
	public void id(){
		String value = (String)row.getAttribute("id");
		if(value != null && !"".equals(value))
			html.append(" id=\""+ value +"\" ");

	}

	/**
	 * 功能描述：生成每行tr的ondblclick事件
	 */
	public void ondblclick(){
		String value = (String)row.getAttribute("ondblclick");
		if(value != null && !"".equals(value)){
				html.append(" ondblclick=\""+value+"\" ");
			}
	}
	/**
	 *
	     * Function: 添加onContextMenu属性
	     * Create author:yixianjian
	     * Create on:2008-5-21
	 */
	public void onContextMenu(){
		String onContextMenu = row.getAttributeAsString("onContextMenu");
		if(StringUtils.isNotBlank(onContextMenu)){
			html.append(" onContextMenu=\"" + onContextMenu + "\"");
		}
	}
}
